package com.ttmall.controller;

import com.ttmall.common.pojo.EasyUITreeNode;
import com.ttmall.common.pojo.TaotaoResult;
import com.ttmall.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by GalaIO on 2018/1/17.
 */
@RestController
@RequestMapping("/content/category")
public class ContentCategoryController {
    @Autowired
    private ContentCategoryService contentCategoryService;

    @RequestMapping("/list")
    public List<EasyUITreeNode> listContentCategory(@RequestParam(defaultValue = "0") Long id) {
        return contentCategoryService.listContentCategory(id);
    }

    @RequestMapping("/create")
    public TaotaoResult createContentCat(Long parentId, String name) {
        return contentCategoryService.createContentCat(parentId, name);
    }

    @RequestMapping("/delete")
    public TaotaoResult deleteContentCat(Long parentId, Long id) {
        return contentCategoryService.deleteContentCat(id);
    }
    @RequestMapping("/update")
    public TaotaoResult updateContentCat(Long id, String name) {
        return contentCategoryService.updateContentCat(id, name);
    }

}
